package StudyCode.summary.mycollection;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UnionSets {
	public static <T> Set<T> union(final Set<T>... elements) {
		return ((elements.length == 0) ? Collections.<T>emptySet()
				: new HashSet<T>(elements.length * elements[0].size()) {
			private static final long serialVersionUID = -3161916411604210423L;

			{
				for (final Set<T> s : elements) {
					addAll(s);
				}
			}
		});
	}
}
